package com.distributer.policy.thread;

import java.util.concurrent.ArrayBlockingQueue;

import com.distributer.policy.request.Request;

/**
 * 初始化保单处理线程
 * @author Administrator
 *
 */
public class PolicyRequestHandlerThreadInit {

	private PolicyRequestHandlerThreadInit(){
		RequestQueue requestQueues = RequestQueue.instance();
		for (int i = 0; i < 10; i++) {
			ArrayBlockingQueue<Request> requestQueue = new ArrayBlockingQueue<Request>(1024);
			PolicyRequestHandlerTask policyRequestHandlerTask = new PolicyRequestHandlerTask(requestQueue);
			Thread policyRequestHandlerThread = new Thread(policyRequestHandlerTask);
			policyRequestHandlerThread.setName("policyRequestHandlerThread-"+i);
			policyRequestHandlerThread.setDaemon(true);
			policyRequestHandlerThread.start();
			requestQueues.addQueue(requestQueue);
		}
	}
	
	private static class PolicyRequestHandlerThreadInitInstance{
		private static PolicyRequestHandlerThreadInit policyRequestHandlerThreadInitInstance;
		
		static{
			policyRequestHandlerThreadInitInstance = new PolicyRequestHandlerThreadInit();
		}
		
		private PolicyRequestHandlerThreadInitInstance(){}
		
		private static PolicyRequestHandlerThreadInit instance(){
			return policyRequestHandlerThreadInitInstance;
		}	
	
	}
	
	public static PolicyRequestHandlerThreadInit instance(){
		return PolicyRequestHandlerThreadInitInstance.instance();
	}
}
